package com.wangxinyuchuan.demo.template;

/**
 * @author wangxinyuchuan
 * @date 2023/4/9 11:37 PM
 */
public class StringDisplay extends AbstractDisplay{

    private String string;

    public StringDisplay(String s) {
        this.string = s;
    }
    @Override
    public void open() {
        printLine();
    }

    @Override
    public void print() {
        System.out.println("｜" + string + "|");
    }

    @Override
    public void close() {
        printLine();
    }

    private void printLine() {
        System.out.print("+");
        for (int i = 0; i < string.length(); i++) {
            System.out.print("-");
        }
        System.out.println("+");
    }
}
